package rest.jbpm.wrappers.lists;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import rest.jbpm.wrappers.Definition;

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "processDefinitions", propOrder = {
    "definitions"})
public class DefinitionList {

	private List<Definition> processDefinitions;
	private String baseUri;
	
	protected DefinitionList() {
		
	}
	
	public DefinitionList(Collection<org.jbpm.api.ProcessDefinition> definitions,
			String baseUri) {
		
		this.baseUri = baseUri;
		processDefinitions = new ArrayList<Definition>();
		if(definitions == null) return;
        
		for(org.jbpm.api.ProcessDefinition def : definitions)
			processDefinitions.add(new Definition(def,baseUri));

	}
   
	
	@XmlElement(name="definition", required=true)
	public List<Definition> getDefinitions() {
		return processDefinitions;
	}
}
